{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Exercises\n",
    "The aim of this notebook is to take interactive notes on some of the exercises from chapter 2."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import plotly.graph_objs as go\n",
    "from plotly.offline import iplot, plot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "----\n",
    "The equivalent form of the bernoulli distribution is of the form\n",
    "$$\n",
    "    p(x|\\mu) = \\left(\\frac{1-\\mu}{2}\\right)^{(1-x)/2}\\left(\\frac{1+\\mu}{2}\\right)^{(1+x)/2}\n",
    "$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def sbern(x, mu):\n",
    "    return ((1 - mu) / 2) ** ((1 - x) / 2) * ((1 + mu) / 2) ** ((1 + x) / 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$\\mu$ takes values between $[-1,1]$."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Probabilities for $-1$ and $1$**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "0f70fe40b004479fb70d7435874e35c8",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "FigureWidget({\n",
       "    'data': [{'name': 'p(x=1|mu)',\n",
       "              'type': 'scatter',\n",
       "              'uid': '297e5…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = 1\n",
    "mu = np.linspace(-1, 1, 100)\n",
    "\n",
    "data = [\n",
    "    {\"x\": mu,\n",
    "     \"y\": sbern(1, mu),\n",
    "     \"name\": \"p(x=1|mu)\"},\n",
    "    \n",
    "    {\"x\": mu,\n",
    "     \"y\": sbern(-1, mu),\n",
    "     \"name\": \"p(x=-1|mu)\"}\n",
    "]\n",
    "\n",
    "layout = {\"title\": \"Probability for bernoulli distribution\",\n",
    "          \"xaxis\": {\n",
    "              \"title\": \"mu\"\n",
    "          }}\n",
    "\n",
    "fig = go.FigureWidget(data=data, layout=layout)\n",
    "fig"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Entropy for the symmetrical form of the Bernoulli distribution**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "d1f4b6bc405f469d84d2d90d321116e4",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "FigureWidget({\n",
       "    'data': [{'name': 'H[x]',\n",
       "              'type': 'scatter',\n",
       "              'uid': '50137166-0…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "mu = np.linspace(-0.9, 0.9, 101)\n",
    "def bern_entropy(mu): return -(np.log((1 - mu ** 2) / 4) + mu * np.log((1 + mu) / (1 - mu))) / 2\n",
    "\n",
    "data = [\n",
    "    {\"x\": mu,\n",
    "     \"y\": bern_entropy(mu),\n",
    "     \"name\": \"H[x]\"}\n",
    "]\n",
    "\n",
    "fig = go.FigureWidget(data=data)\n",
    "fig"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "----------\n",
    "**Ex 2.20**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy import init_printing\n",
    "from sympy import symbols, Matrix\n",
    "import sympy as sym\n",
    "init_printing()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "v11, v12, v21, v22 = symbols(\"v11, v12, v21, v22\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "u11, u12, u21, u22 = symbols(\"u11, u12, u21, u22\")\n",
    "a1, a2 = symbols(\"a1, a2\")\n",
    "l1, l2 = symbols(\"lambda_1, lambda_2\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = Matrix(2, 1, [a1, a2])\n",
    "L = Matrix(2, 2, [l1, 0, 0, l2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "V = Matrix([[v11, v12], [v21, v22]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADUAAAAyBAMAAAAOzY77AAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMA74lUMhCrmXbNZt0iu0TKQvJ9AAAACXBIWXMAAA7EAAAOxAGVKw4bAAABKElEQVQ4EWOQ//+JAQtg+v9fgEHYxRWLFAOri7MAgwg2GZAYC1Y51qJFDgg5wwCQShjgNGDdA5NjTc9HkVvIwKAJk2Ng6EeRu8bAYB8Atw9V7hsDw3sD7HKs34FyDdjleICB4a+AQw6oD5ccPjMZgG6xx+EWhrsMDOtx+QHo90pcfuc2YAXGADSsy+SnLYAFJpBm1WhzgMshiSOY2OMIIj8qxxCupYIIKxgLGi6TGaIPwIRANLMokIDIcQkwME1Akgsr+wqX401gYAbx4IADIcefwMD3GS4BZCDJxRcw8P3AIXdegYEFJfMi6TtfgFsOn5lAtzDjcgvvBQYuXH4A+p0d2e/IfmDYzBDogMMPDEEdKchS7Ik/s2DhiSyOYA+y9ImvjMRTtgIAz1JTjnSjBSoAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$\\left[\\begin{matrix}1 & 0\\\\0 & 1\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡1  0⎤\n",
       "⎢    ⎥\n",
       "⎣0  1⎦"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "U = Matrix([[u11, u12], [u21, u22]])\n",
    "(U @ U.inv()).applyfunc(sym.simplify)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "from scipy import linalg"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'np' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-8-342d81036b04>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m S = np.array([\n\u001b[0m\u001b[1;32m      2\u001b[0m     \u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m     \u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m ])\n",
      "\u001b[0;31mNameError\u001b[0m: name 'np' is not defined"
     ]
    }
   ],
   "source": [
    "S = np.array([\n",
    "    [1, 2],\n",
    "    [-2, 2]\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "linalg.eig(S)[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "np.dot(_76[:,0], _76[:,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHIAAAAyBAMAAAByq5IiAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMA74lUMhC73atEImbNmXaSJeyhAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACQ0lEQVRIDe2Wv0scQRTHH3c7d+epFzam0uI2gSSdMTaWOYMp1VNELGJiI4E0bplcY4pEDhEVG9tthHTef5Crk0aIlY0iCFqIP0iQaGR9783+uJ3dETwCaW7hdr/vfeczOzfsflkouudw9+OZewZdQ6/uDsLE0HN40ARHyCCRmYtqdWH+j26KuQ/V6jt3VbGZzLsOgNGjWEG5eYlysBbUUjAJ3+pY9StWULb/RZm2gloKSWZoezsVKyznLNRbYc1KkqJYwlkVKyzHfqHuC2tWkoQXttKPlOmLSCkLj8xdJ3hha0VdKloeKe6HwxLUmBVveqSRMGnD4OEG7UuP/Ip1we/FrvlP2NpT2pIUM9iehtTxyGfF53ISz2ILercPS6EtyckydvbhIFf/CDnUX8IBqMQsngpWobyUXUXLePSebEkuonpzBaWOGrQ9dGCtm6zgyDlIn9QM+AFkZWCdLCY7z0yz6OITfw/HZPFXISs4dk3TdOmJp+e3Ah3wlpYo7+kPGoVSAum7xqkhJx2gTiOZP30Klp7cTNkpJsV3lRTLa/tlPTl11PuYySlabOSeVCf9T9n3zhUQO+OkG1fLnnHyE0au+7xxsQtaWZdfgBgZG6trtEjdzvh93qFWUsvtaCU1wP9Nas5hfVK/fOLokppy+JaknmmzdUnNOaxP6rr4rU1qwByOkv57xUmdtoFGRLNPJjXlcCIpk/q1A7qkphxOJDmpBW6eJqk5hxNJXvT0hqVLasrhW5J63rX/QVI3/5Xa9JfxDfDPxyiZR7TRAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$$\\left[\\begin{matrix}\\Sigma_{x_{11}} & \\Sigma_{x_{12}}\\\\\\Sigma_{x_{21}} & \\Sigma_{x_{22}}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡\\Sigma_{x_{11}}  \\Sigma_{x_{12}}⎤\n",
       "⎢                                ⎥\n",
       "⎣\\Sigma_{x_{21}}  \\Sigma_{x_{22}}⎦"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1, x2 = symbols(\"x1 x2\")\n",
    "mx1, mx2 = symbols(\"\\mu_{x1} \\mu_{x2}\")\n",
    "Sx11, Sx12, Sx21, Sx22 = symbols(\"\\Sigma_{x_{11}} \\Sigma_{x_{12}} \\Sigma_{x_{21}} \\Sigma_{x_{22}}\")\n",
    "\n",
    "x = Matrix([[x1, x2]]).T\n",
    "mx = Matrix([[mx1, mx2]]).T\n",
    "Sx = Matrix([\n",
    "    [Sx11, Sx12],\n",
    "    [Sx21, Sx22]\n",
    "])\n",
    "Sx"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAG8AAAAyBAMAAACg+5h6AAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMA74lUMhC73atEImbNmXaSJeyhAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABxklEQVRIDe2WPUsDQRCGB3ObL4wkaqVF/ABLCTYWFn7FVoKFiBhNbXW1CKmUYBVsbK8Rkj9gaxobK8HOSvwDoiBBJKyzd7tJLplZSCzNNtnbZ57dy3C8d5CVnzDoGJMyDVP5nUE9EPntNEwPrCnB8cVos1K5LH8zO5A0EJPSwz1mGZGkgQj3DZRWGJGkWoyqxqY4kaJaFNkNgAgnUlSLsO5yllonqBHjLZtIUCOKSZtIUCM6TzaRoEasoTfBugTVoiihVITk+WGVsCmqxf0C1r9Bam0Z4AIgri47I0ydhVNEWrzC6fEPgMjB9Qwk5r2OhbMwjcINrgVi6iOTyUp8yOu4dAYQ8/C3PXroOJzgDekTdVGy6hT6RbODobCKK2GxtnhHnGhEQ8Vjn/i6+WARDT1QrQuf6O/d9x/NiZqKlz1S3G3lnPfnUHHXBdKYbJJiV5VtStyqrbzD/o9IRm67ESQNmkNGblskqe7qKJBhFMg6kLeWPEsgI+UCuZRwLYGMlAvkhviyBDJSNpAjbo9onnY/kJFygXzkMaIfyEiZQBb4tgq/O8yJKpAVZQK5eDvHiGoDpFwgl6VrCWSkfw/koT87h/3Q/QVDM7IrWRt8KwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\left[\\begin{matrix}\\Sigma_{z_{11}} & \\Sigma_{z_{12}}\\\\\\Sigma_{z_{21}} & \\Sigma_{z_{22}}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡\\Sigma_{z_{11}}  \\Sigma_{z_{12}}⎤\n",
       "⎢                                ⎥\n",
       "⎣\\Sigma_{z_{21}}  \\Sigma_{z_{22}}⎦"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z1, z2 = symbols(\"z1 z2\")\n",
    "mz1, mz2 = symbols(\"\\mu_{z1} \\mu_{z2}\")\n",
    "Sz11, Sz12, Sz21, Sz22 = symbols(\"\\Sigma_{z_{11}} \\Sigma_{z_{12}} \\Sigma_{z_{21}} \\Sigma_{z_{22}}\")\n",
    "\n",
    "z = Matrix([[z1, z2]]).T\n",
    "mz = Matrix([[mz1, mz2]]).T\n",
    "Sz = Matrix([\n",
    "    [Sz11, Sz12],\n",
    "    [Sz21, Sz22]\n",
    "])\n",
    "Sz"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAACGgAAAAWBAMAAABk2SVmAAAAMFBM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s6eTFkZ958EtDvcJ67XzgwV2M7KA3g0DY4sKcb/tqLldkXiVfkZ5QkTJtUW+YF6fdHctA3og/JllAZH+6f9l6aARdcz7hO8TNG+XdZT99E/MwD41ouQSVRNgnWFCTyQUuGe80MdABAatNlSvhxTiqWQay+oX1Vh9yD3E+MenxsD//UbkSUifCuQP4h31mO8iv7dOH7h5mN/5nXcPWq4SlerasiWNfOPyY/dAoMot9XsMLXnfXab3AfmXIQiI7hd+kEHIbv7gzkxdHPrC97V4mZxdtb5/lW91BbwaBiMWFOd9jQ65UZF4lX5YeEJUo0xb1hnlJ3tmzDORNMR0OxHxn39B6aARdUz7hO8TNG+nd+vPXjbSOyiWoJMI+QV8doJLxTiFOLCRQqKJypbwYRzXLPy5XWF/0YWaK84lJj4f9+Y/KlZA6Ec4dyLpW61UOp+RfQf9/SLaW39p+phz08lFLnnz9pj40miG76Pg7oHqbXu5duAbtDz0tSF6mHF4hYysJlSjTlnVxV2cjb9QfuS7rOtfT03dNIrW7doDyk1FcXpV1eQX7wCaYde1M42OXgKsKytXYi3hDbjV3jW2924e7rsYZlTMls26N69JL3fFKr6uSee6ljc59N1VZWXfNXdv9CSHX7cRej3znts/ZkTEdEypSHhOaB0NCYudedGKn/5/WVadLck3Mi7CNiVoflrsQuaDABQUuKPC/UeC/ebTQ90DYuisAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$\\left(- \\mu_{x1} + x_{1}\\right) \\left(\\Sigma_{x_{11}} \\left(- \\mu_{x1} + x_{1}\\right) + \\Sigma_{x_{21}} \\left(- \\mu_{x2} + x_{2}\\right)\\right) + \\left(- \\mu_{x2} + x_{2}\\right) \\left(\\Sigma_{x_{12}} \\left(- \\mu_{x1} + x_{1}\\right) + \\Sigma_{x_{22}} \\left(- \\mu_{x2} + x_{2}\\right)\\right) + \\left(\\Sigma_{z_{11}} \\left(- \\mu_{z1} + x_{1} + z_{1}\\right) + \\Sigma_{z_{21}} \\left(- \\mu_{z2} + x_{2} + z_{2}\\right)\\right) \\left(- \\mu_{z1} + x_{1} + z_{1}\\right) + \\left(\\Sigma_{z_{12}} \\left(- \\mu_{z1} + x_{1} + z_{1}\\right) + \\Sigma_{z_{22}} \\left(- \\mu_{z2} + x_{2} + z_{2}\\right)\\right) \\left(- \\mu_{z2} + x_{2} + z_{2}\\right)$$"
      ],
      "text/plain": [
       "(-\\mu_{x1} + x₁)⋅(\\Sigma_{x_{11}}⋅(-\\mu_{x1} + x₁) + \\Sigma_{x_{21}}⋅(-\\mu_{x2\n",
       "} + x₂)) + (-\\mu_{x2} + x₂)⋅(\\Sigma_{x_{12}}⋅(-\\mu_{x1} + x₁) + \\Sigma_{x_{22}\n",
       "}⋅(-\\mu_{x2} + x₂)) + (\\Sigma_{z_{11}}⋅(-\\mu_{z1} + x₁ + z₁) + \\Sigma_{z_{21}}\n",
       "⋅(-\\mu_{z2} + x₂ + z₂))⋅(-\\mu_{z1} + x₁ + z₁) + (\\Sigma_{z_{12}}⋅(-\\mu_{z1} + \n",
       "x₁ + z₁) + \\Sigma_{z_{22}}⋅(-\\mu_{z2} + x₂ + z₂))⋅(-\\mu_{z2} + x₂ + z₂)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sym.collect(((x - mx).T * Sx * (x - mx))[0] + ((z + x - mz).T * Sz * (z + x - mz))[0], (x1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "z = sym.MatrixSymbol(\"z\", 2, 1)\n",
    "mz = sym.MatrixSymbol(\"m_z\", 2, 1)\n",
    "Sz = sym.MatrixSymbol(\"S_z\", 2, 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = sym.MatrixSymbol(\"x\", 2, 1)\n",
    "mx = sym.MatrixSymbol(\"m_x\", 2, 1)\n",
    "Sx = sym.MatrixSymbol(\"S_x\", 2, 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAm4AAAAcBAMAAAAq8y7DAAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAMkS7zRCZdiKJ71Rmq90icBAQAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAHDElEQVRoBe1YXWhcRRQ+u8nd7GY3afAXVMy+SR9Mi0Xqg9K0rqCg5UILrQ8lkdZKocpSaUKF2KWCCv5kBWsetDWUivggBMFaROuqQbFYrahNRaxR4l8VG4XSSi31zJ05c8/ceyabNM2b83Bn5jvnfOe7Z+feubMAUjt8bMWx7xuCpfT6xvMP/isYELpChueN+nP6ZPojFk5ldJtfw+dQKgt33BGWpuEDwQBw1QkRnj/oz+mT6Y+4lCovS91aUIWNUKylcIB1kFsKB6EqmOCQBM4ZS6sxOdNMXpkLrxLFZJamFGVC+A2yKRiBK6GzDmW4UbJdkroJakzOdEqvzAVXqbS0hmlFEPwtgBHUV8au0IjG7sXU7WkXnWlWqqWsopooZ8oVAa/MpirzDYlvllik+wHJOXtaQhW2JCrzT8Z8YEvdvu103fLp5eujAjieMolqdM6UL4BXZjOV8JjANnsIdefFChUmfSR7I8OANrc0YM00eeq6tdZoPot+bdJHVqNzJn1x7pXZTCXcKbDNHkLdhX7JveWoRd+yo2hwW3Qd1uBmgFJvcRm2m8HsCx+57smZy1aoanvR9B41OqdytY46ziuzmcpSvybwXF2VkZMDoe72MSl2UcOiTgCA/njrjOzBX/io0C2buv1qA8WByxaMaidbDllN/MFoHXWcV2YzlZ01TeC5uiojJwcKRqE7lGK7uyzqBEAGS4UNv0awZVFexnq+raD8pLr6m8sGq7SnLYeoxuRUrtZRx/lkNlMJz+p43zWhUrm50Co4zGIXH39iqLr4YfzOOPWNhSlg3dCuHdXsifN1ZWkbVdfgwnOq0+3xUxM4a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n+31AW1tgCoQBmxaE+L2iMOwOI56xFNQo36c00P6kHtm7SPx9sHVDdiI31LrE2cJW5d0aYt3zOUi+fqAlkDoS61YdDqrEFAutTVgRaqzHKnQHEc303mBdHgo3O9UHN0Elq2DoA6xinNyNJJlcJAT4atpX67TAeZKYzZiKQORDqTr7YdWS8QGJaPuoL2cxxbqkxix7mp/dCPYUqIPU/kqzmrBjcHHRU7nL8b3Fm0WS4MOm+2dMuhKDuzChNeB8vEI7G4yPxUH3M0GpCVPjfMphYvIPXOY5NqRfVxOsgjpzViKvMl/Fv9bgJ/1tu2DayO3aYcaR0f5v28C8Q8v2BBlioxGqKN93YxzMq1VIGQc0c1kGCjqmEZ178kFsTuzE3NR9HulPPCh4CvAvEcJbYY9fUubkO5iGomcM6YEQ45Cqhes0drnW+s2L/3BmEVT53EjHiYtSIRAgunMoo4xu+vH78fr9pvpaLUONLuYAqfSn/x5tU4D/oZiTqGmd0igAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\left(-m_{x}^T + x^T\\right) S_{x}^{-1} \\left(-m_{x} + x\\right) + \\left(-m_{x}^T + x^T + z^T\\right) S_{z}^{-1} \\left(-m_{x} + x + z\\right)$$"
      ],
      "text/plain": [
       "⎛   T    T⎞   -1             ⎛   T    T    T⎞    -1              \n",
       "⎝-mₓ  + x ⎠⋅Sₓ  ⋅(-mₓ + x) + ⎝-mₓ  + x  + z ⎠⋅S_z  ⋅(-mₓ + x + z)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "((x - mx).T @ Sx.inverse() @ (x - mx)) +((z + x - mx).T @ Sz.inverse() @ (z  + x - mx))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "state": {
     "0f70fe40b004479fb70d7435874e35c8": {
      "buffers": [
       {
        "data": "AAAAAAAA8L8Fav1KgVrvvwrU+pUCte6/ED744IMP7r8VqPUrBWrtvxoS83aGxOy/H3zwwQcf7L8k5u0MiXnrvylQ61cK1Oq/Lrrooosu6r80JObtDInpvzmO4ziO4+i/Pvjggw8+6L9DYt7OkJjnv0jM2xkS8+a/TjbZZJNN5r9SoNavFKjlv1gK1PqVAuW/XXTRRRdd5L9i3s6QmLfjv2dIzNsZEuO/bLLJJpts4r9yHMdxHMfhv3aGxLydIeG/fPDBBx984L8CtX6lQK3fvwyJeTtDYt6/Fl100UUX3b8gMW9nSMzbvywFav1Kgdq/Ntlkk0022b9ArV8pUOvXv0qBWr9SoNa/VFVVVVVV1b9eKVDrVwrUv2j9SoFav9K/dNFFF1100b9+pUCtXynQvxDzdobEvM2/JJtssskmy784Q2LezpDIv0zrVwrU+sW/ZJNNNtlkw794O0Ni3s7AvxjHcRzHcby/QBdddNFFt79oZ0jM2xmyvyBvZ0jM26m/AB988MEHn79Av1Kg1q+Ev4C/UqDWr4Q/QB988MEHnz9Ab2dIzNupP3BnSMzbGbI/UBdddNFFtz8gx3Ecx3G8P4A7Q2LezsA/aJNNNtlkwz9Q61cK1PrFP0BDYt7OkMg/KJtssskmyz8Y83aGxLzNP4ClQK1fKdA/eNFFF1100T9s/UqBWr/SP2ApUOtXCtQ/WFVVVVVV1T9MgVq/UqDWP0StXylQ69c/ONlkk0022T8wBWr9SoHaPyQxb2dIzNs/GF100UUX3T8QiXk7Q2LePwS1fqVArd8/fvDBBx984D94hsS8nSHhP3Icx3Ecx+E/brLJJpts4j9oSMzbGRLjP2TezpCYt+M/XnTRRRdd5D9aCtT6lQLlP1Sg1q8UqOU/TjbZZJNN5j9KzNsZEvPmP0Ri3s6QmOc/QPjggw8+6D86juM4juPoPzYk5u0Miek/MLrooosu6j8qUOtXCtTqPybm7QyJees/IHzwwQcf7D8cEvN2hsTsPxao9SsFau0/ED744IMP7j8M1PqVArXuPwZq/UqBWu8/AAAAAAAA8D8=",
        "encoding": "base64",
        "path": [
         "_data",
         0,
         "x",
         "value"
        ]
       },
       {
        "data": "AAAAAAAAAABgv1Kg1q+EP2C/UqDWr5Q/AB988MEHnz9Yv1Kg1q+kPzBvZ0jM26k/CB988MEHrz9wZ0jM2xmyP1y/UqDWr7Q/SBdddNFFtz8wb2dIzNu5PxzHcRzHcbw/CB988MEHvz96O0Ni3s7AP3BnSMzbGcI/ZJNNNtlkwz9cv1Kg1q/EP1DrVwrU+sU/RhdddNFFxz88Q2LezpDIPzJvZ0jM28k/KJtssskmyz8cx3Ecx3HMPxTzdobEvM0/CB988MEHzz9/pUCtXynQP3o7Q2LeztA/ddFFF1100T9wZ0jM2xnSP2r9SoFav9I/ZZNNNtlk0z9gKVDrVwrUP1u/UqDWr9Q/VlVVVVVV1T9R61cK1PrVP0yBWr9SoNY/RhdddNFF1z9BrV8pUOvXPzxDYt7OkNg/N9lkk0022T8yb2dIzNvZPy0Fav1Kgdo/J5tssskm2z8iMW9nSMzbPx3HcRzHcdw/GF100UUX3T8T83aGxLzdPw6JeTtDYt4/CB988MEH3z8DtX6lQK3fP3+lQK1fKeA/ffDBBx984D96O0Ni3s7gP3eGxLydIeE/ddFFF1104T9yHMdxHMfhP3BnSMzbGeI/bbLJJpts4j9q/UqBWr/iP2hIzNsZEuM/ZZNNNtlk4z9j3s6QmLfjP2ApUOtXCuQ/XnTRRRdd5D9bv1Kg1q/kP1gK1PqVAuU/VlVVVVVV5T9ToNavFKjlP1HrVwrU+uU/TjbZZJNN5j9MgVq/UqDmP0nM2xkS8+Y/RhdddNFF5z9EYt7OkJjnP0GtXylQ6+c/P/jggw8+6D88Q2LezpDoPzmO4ziO4+g/N9lkk0026T80JObtDInpPzJvZ0jM2+k/L7rooosu6j8tBWr9SoHqPypQ61cK1Oo/J5tssskm6z8l5u0MiXnrPyIxb2dIzOs/IHzwwQcf7D8dx3Ecx3HsPxsS83aGxOw/GF100UUX7T8VqPUrBWrtPxPzdobEvO0/ED744IMP7j8OiXk7Q2LuPwvU+pUCte4/CB988MEH7z8Gav1KgVrvPwO1fqVAre8/AAAAAAAA8D8=",
        "encoding": "base64",
        "path": [
         "_data",
         0,
         "y",
         "value"
        ]
       },
       {
        "data": "AAAAAAAA8L8Fav1KgVrvvwrU+pUCte6/ED744IMP7r8VqPUrBWrtvxoS83aGxOy/H3zwwQcf7L8k5u0MiXnrvylQ61cK1Oq/Lrrooosu6r80JObtDInpvzmO4ziO4+i/Pvjggw8+6L9DYt7OkJjnv0jM2xkS8+a/TjbZZJNN5r9SoNavFKjlv1gK1PqVAuW/XXTRRRdd5L9i3s6QmLfjv2dIzNsZEuO/bLLJJpts4r9yHMdxHMfhv3aGxLydIeG/fPDBBx984L8CtX6lQK3fvwyJeTtDYt6/Fl100UUX3b8gMW9nSMzbvywFav1Kgdq/Ntlkk0022b9ArV8pUOvXv0qBWr9SoNa/VFVVVVVV1b9eKVDrVwrUv2j9SoFav9K/dNFFF1100b9+pUCtXynQvxDzdobEvM2/JJtssskmy784Q2LezpDIv0zrVwrU+sW/ZJNNNtlkw794O0Ni3s7AvxjHcRzHcby/QBdddNFFt79oZ0jM2xmyvyBvZ0jM26m/AB988MEHn79Av1Kg1q+Ev4C/UqDWr4Q/QB988MEHnz9Ab2dIzNupP3BnSMzbGbI/UBdddNFFtz8gx3Ecx3G8P4A7Q2LezsA/aJNNNtlkwz9Q61cK1PrFP0BDYt7OkMg/KJtssskmyz8Y83aGxLzNP4ClQK1fKdA/eNFFF1100T9s/UqBWr/SP2ApUOtXCtQ/WFVVVVVV1T9MgVq/UqDWP0StXylQ69c/ONlkk0022T8wBWr9SoHaPyQxb2dIzNs/GF100UUX3T8QiXk7Q2LePwS1fqVArd8/fvDBBx984D94hsS8nSHhP3Icx3Ecx+E/brLJJpts4j9oSMzbGRLjP2TezpCYt+M/XnTRRRdd5D9aCtT6lQLlP1Sg1q8UqOU/TjbZZJNN5j9KzNsZEvPmP0Ri3s6QmOc/QPjggw8+6D86juM4juPoPzYk5u0Miek/MLrooosu6j8qUOtXCtTqPybm7QyJees/IHzwwQcf7D8cEvN2hsTsPxao9SsFau0/ED744IMP7j8M1PqVArXuPwZq/UqBWu8/AAAAAAAA8D8=",
        "encoding": "base64",
        "path": [
         "_data",
         1,
         "x",
         "value"
        ]
       },
       {
        "data": "AAAAAAAA8D8CtX6lQK3vPwVq/UqBWu8/CB988MEH7z8K1PqVArXuPw2JeTtDYu4/ED744IMP7j8S83aGxLztPxSo9SsFau0/F1100UUX7T8aEvN2hsTsPxzHcRzHcew/H3zwwQcf7D8iMW9nSMzrPyTm7QyJees/J5tssskm6z8pUOtXCtTqPywFav1Kgeo/Lrrooosu6j8xb2dIzNvpPzQk5u0Miek/Ntlkk0026T85juM4juPoPztDYt7OkOg/Pvjggw8+6D9ArV8pUOvnP0Ni3s6QmOc/RhdddNFF5z9IzNsZEvPmP0uBWr9SoOY/TjbZZJNN5j9Q61cK1PrlP1Kg1q8UqOU/VVVVVVVV5T9YCtT6lQLlP1q/UqDWr+Q/XXTRRRdd5D9gKVDrVwrkP2LezpCYt+M/ZJNNNtlk4z9nSMzbGRLjP2r9SoFav+I/bLLJJpts4j9vZ0jM2xniP3Icx3Ecx+E/dNFFF1104T92hsS8nSHhP3k7Q2LezuA/fPDBBx984D9+pUCtXyngPwK1fqVArd8/Bh988MEH3z8MiXk7Q2LePxLzdobEvN0/Fl100UUX3T8cx3Ecx3HcPyAxb2dIzNs/Jptssskm2z8sBWr9SoHaPzBvZ0jM29k/Ntlkk0022T86Q2LezpDYP0CtXylQ69c/RBdddNFF1z9KgVq/UqDWP1DrVwrU+tU/VFVVVVVV1T9av1Kg1q/UP14pUOtXCtQ/ZJNNNtlk0z9o/UqBWr/SP25nSMzbGdI/dNFFF1100T94O0Ni3s7QP36lQK1fKdA/BB988MEHzz8Q83aGxLzNPxzHcRzHccw/JJtssskmyz8wb2dIzNvJPzhDYt7OkMg/RBdddNFFxz9M61cK1PrFP1i/UqDWr8Q/ZJNNNtlkwz9sZ0jM2xnCP3g7Q2LezsA/AB988MEHvz8Yx3Ecx3G8PyhvZ0jM27k/QBdddNFFtz9Yv1Kg1q+0P2hnSMzbGbI/AB988MEHrz8gb2dIzNupP1C/UqDWr6Q/AB988MEHnz9Av1Kg1q+UP0C/UqDWr4Q/AAAAAAAAAAA=",
        "encoding": "base64",
        "path": [
         "_data",
         1,
         "y",
         "value"
        ]
       }
      ],
      "model_module": "plotlywidget",
      "model_module_version": "^0.7.1",
      "model_name": "FigureModel",
      "state": {
       "_config": {
        "plotlyServerURL": "https://plot.ly"
       },
       "_data": [
        {
         "name": "p(x=1|mu)",
         "type": "scatter",
         "uid": "297e5e45-0fda-436e-b3d5-2525c29c2cf6",
         "x": {
          "dtype": "float64",
          "shape": [
           100
          ]
         },
         "y": {
          "dtype": "float64",
          "shape": [
           100
          ]
         }
        },
        {
         "name": "p(x=-1|mu)",
         "type": "scatter",
         "uid": "946ebc88-6138-4fbe-ab6c-805129fba672",
         "x": {
          "dtype": "float64",
          "shape": [
           100
          ]
         },
         "y": {
          "dtype": "float64",
          "shape": [
           100
          ]
         }
        }
       ],
       "_js2py_layoutDelta": {
        "layout_delta": {
         "annotations": [],
         "autosize": true,
         "calendar": "gregorian",
         "clickmode": "event",
         "colorscale": {
          "diverging": [
           [
            0,
            "rgb(5,10,172)"
           ],
           [
            0.35,
            "rgb(106,137,247)"
           ],
           [
            0.5,
            "rgb(190,190,190)"
           ],
           [
            0.6,
            "rgb(220,170,132)"
           ],
           [
            0.7,
            "rgb(230,145,90)"
           ],
           [
            1,
            "rgb(178,10,28)"
           ]
          ],
          "sequential": [
           [
            0,
            "rgb(220,220,220)"
           ],
           [
            0.2,
            "rgb(245,195,157)"
           ],
           [
            0.4,
            "rgb(245,160,105)"
           ],
           [
            1,
            "rgb(178,10,28)"
           ]
          ],
          "sequentialminus": [
           [
            0,
            "rgb(5,10,172)"
           ],
           [
            0.35,
            "rgb(40,60,190)"
           ],
           [
            0.5,
            "rgb(70,100,245)"
           ],
           [
            0.6,
            "rgb(90,120,245)"
           ],
           [
            0.7,
            "rgb(106,137,247)"
           ],
           [
            1,
            "rgb(220,220,220)"
           ]
          ]
         },
         "colorway": [
          "#1f77b4",
          "#ff7f0e",
          "#2ca02c",
          "#d62728",
          "#9467bd",
          "#8c564b",
          "#e377c2",
          "#7f7f7f",
          "#bcbd22",
          "#17becf"
         ],
         "dragmode": "zoom",
         "font": {
          "color": "#444",
          "family": "\"Open Sans\", verdana, arial, sans-serif",
          "size": 12
         },
         "height": 470,
         "hidesources": false,
         "hoverdistance": 20,
         "hoverlabel": {
          "font": {
           "family": "Arial, sans-serif",
           "size": 13
          },
          "namelength": 15
         },
         "hovermode": "x",
         "images": [],
         "legend": {
          "bgcolor": "#fff",
          "bordercolor": "#444",
          "borderwidth": 0,
          "font": {
           "color": "#444",
           "family": "\"Open Sans\", verdana, arial, sans-serif",
           "size": 12
          },
          "orientation": "v",
          "traceorder": "normal",
          "valign": "middle",
          "x": 1.02,
          "xanchor": "left",
          "y": 1,
          "yanchor": "auto"
         },
         "margin": {
          "autoexpand": true,
          "b": 80,
          "l": 80,
          "pad": 0,
          "r": 80,
          "t": 100
         },
         "modebar": {
          "activecolor": "rgba(68, 68, 68, 0.7)",
          "bgcolor": "rgba(255, 255, 255, 0.5)",
          "color": "rgba(68, 68, 68, 0.3)",
          "orientation": "h"
         },
         "paper_bgcolor": "#fff",
         "plot_bgcolor": "#fff",
         "separators": ".,",
         "shapes": [],
         "showlegend": true,
         "sliders": [],
         "spikedistance": 20,
         "title": {
          "font": {
           "color": "#444",
           "family": "\"Open Sans\", verdana, arial, sans-serif",
           "size": 17
          },
          "pad": {
           "b": 0,
           "l": 0,
           "r": 0,
           "t": 0
          },
          "x": 0.5,
          "xanchor": "auto",
          "xref": "container",
          "y": "auto",
          "yanchor": "auto",
          "yref": "container"
         },
         "updatemenus": [],
         "width": 985.469,
         "xaxis": {
          "anchor": "y",
          "automargin": false,
          "autorange": true,
          "color": "#444",
          "constrain": "range",
          "constraintoward": "center",
          "domain": [
           0,
           1
          ],
          "dtick": 0.5,
          "exponentformat": "B",
          "fixedrange": false,
          "gridcolor": "rgb(238, 238, 238)",
          "gridwidth": 1,
          "hoverformat": "",
          "layer": "above traces",
          "nticks": 0,
          "range": [
           -1,
           1
          ],
          "rangemode": "normal",
          "separatethousands": false,
          "showexponent": "all",
          "showgrid": true,
          "showline": false,
          "showspikes": false,
          "showticklabels": true,
          "side": "bottom",
          "tick0": 0,
          "tickangle": "auto",
          "tickfont": {
           "color": "#444",
           "family": "\"Open Sans\", verdana, arial, sans-serif",
           "size": 12
          },
          "tickformat": "",
          "tickmode": "auto",
          "tickprefix": "",
          "ticks": "",
          "ticksuffix": "",
          "title": {
           "font": {
            "color": "#444",
            "family": "\"Open Sans\", verdana, arial, sans-serif",
            "size": 14
           }
          },
          "type": "linear",
          "visible": true,
          "zeroline": true,
          "zerolinecolor": "#444",
          "zerolinewidth": 1
         },
         "yaxis": {
          "anchor": "x",
          "automargin": false,
          "autorange": true,
          "color": "#444",
          "constrain": "range",
          "constraintoward": "middle",
          "domain": [
           0,
           1
          ],
          "dtick": 0.2,
          "exponentformat": "B",
          "fixedrange": false,
          "gridcolor": "rgb(238, 238, 238)",
          "gridwidth": 1,
          "hoverformat": "",
          "layer": "above traces",
          "nticks": 0,
          "range": [
           -0.05555555555555555,
           1.0555555555555556
          ],
          "rangemode": "normal",
          "separatethousands": false,
          "showexponent": "all",
          "showgrid": true,
          "showline": false,
          "showspikes": false,
          "showticklabels": true,
          "side": "left",
          "tick0": 0,
          "tickangle": "auto",
          "tickfont": {
           "color": "#444",
           "family": "\"Open Sans\", verdana, arial, sans-serif",
           "size": 12
          },
          "tickformat": "",
          "tickmode": "auto",
          "tickprefix": "",
          "ticks": "",
          "ticksuffix": "",
          "title": {
           "font": {
            "color": "#444",
            "family": "\"Open Sans\", verdana, arial, sans-serif",
            "size": 14
           },
           "text": "Click to enter Y axis title"
          },
          "type": "linear",
          "visible": true,
          "zeroline": true,
          "zerolinecolor": "#444",
          "zerolinewidth": 1
         }
        },
        "layout_edit_id": 0
       },
       "_js2py_relayout": {},
       "_js2py_restyle": {},
       "_js2py_traceDeltas": {
        "trace_deltas": [
         {
          "connectgaps": false,
          "error_x": {
           "visible": false
          },
          "error_y": {
           "visible": false
          },
          "fill": "none",
          "hoverinfo": "all",
          "hoverlabel": {
           "font": {
            "family": "Arial, sans-serif",
            "size": 13
           },
           "namelength": 15
          },
          "hoveron": "points",
          "hovertemplate": "",
          "hovertext": "",
          "index": 0,
          "legendgroup": "",
          "line": {
           "color": "#1f77b4",
           "dash": "solid",
           "shape": "linear",
           "simplify": true,
           "width": 2
          },
          "mode": "lines",
          "opacity": 1,
          "showlegend": true,
          "stackgroup": "",
          "text": "",
          "uid": "297e5e45-0fda-436e-b3d5-2525c29c2cf6",
          "visible": true,
          "xaxis": "x",
          "xcalendar": "gregorian",
          "yaxis": "y",
          "ycalendar": "gregorian"
         },
         {
          "connectgaps": false,
          "error_x": {
           "visible": false
          },
          "error_y": {
           "visible": false
          },
          "fill": "none",
          "hoverinfo": "all",
          "hoverlabel": {
           "font": {
            "family": "Arial, sans-serif",
            "size": 13
           },
           "namelength": 15
          },
          "hoveron": "points",
          "hovertemplate": "",
          "hovertext": "",
          "index": 1,
          "legendgroup": "",
          "line": {
           "color": "#ff7f0e",
           "dash": "solid",
           "shape": "linear",
           "simplify": true,
           "width": 2
          },
          "mode": "lines",
          "opacity": 1,
          "showlegend": true,
          "stackgroup": "",
          "text": "",
          "uid": "946ebc88-6138-4fbe-ab6c-805129fba672",
          "visible": true,
          "xaxis": "x",
          "xcalendar": "gregorian",
          "yaxis": "y",
          "ycalendar": "gregorian"
         }
        ],
        "trace_edit_id": 0
       },
       "_js2py_update": {},
       "_layout": {
        "template": {},
        "title": {
         "text": "Probability for bernoulli distribution"
        },
        "xaxis": {
         "title": {
          "text": "mu"
         }
        }
       },
       "_py2js_addTraces": {},
       "_py2js_animate": {},
       "_py2js_deleteTraces": {},
       "_py2js_moveTraces": {},
       "_py2js_removeLayoutProps": {},
       "_py2js_removeTraceProps": {},
       "_py2js_restyle": {},
       "_py2js_update": {},
       "_view_count": 2
      }
     },
     "d1f4b6bc405f469d84d2d90d321116e4": {
      "buffers": [
       {
        "data": "zczMzMzM7L/TTWIQWDnsv9nO91Pjpeu/30+Nl24S67/m0CLb+X7qv+xRuB6F6+m/8tJNYhBY6b/4U+Olm8Tov/7UeOkmMei/BFYOLbKd578K16NwPQrnvxBYObTIdua/FtnO91Pj5b8cWmQ730/lvyPb+X5qvOS/KVyPwvUo5L8v3SQGgZXjvzVeukkMAuO/O99PjZdu4r9CYOXQItvhv0jhehSuR+G/TmIQWDm04L9U46WbxCDgv7TIdr6fGt+/wMqhRbbz3b/MzMzMzMzcv9jO91Pjpdu/5dAi2/l+2r/y0k1iEFjZv/7UeOkmMdi/CtejcD0K178W2c73U+PVvyLb+X5qvNS/Lt0kBoGV078630+Nl27Sv0bhehSuR9G/UuOlm8Qg0L/AyqFFtvPNv9jO91Pjpcu/8NJNYhBYyb8I16NwPQrHvyDb+X5qvMS/ON9PjZduwr9Q46WbxCDAv9jO91Pjpbu/CNejcD0Kt78430+Nl26yv9DO91Pjpau/MN9PjZduor8g30+Nl26SvwAAAAAAAKA8YN9PjZdukj9Q30+Nl26iP+DO91Pjpas/QN9PjZdusj8Q16NwPQq3P9jO91Pjpbs/VOOlm8QgwD8830+Nl27CPyTb+X5qvMQ/DNejcD0Kxz/00k1iEFjJP9zO91Pjpcs/xMqhRbbzzT9W46WbxCDQP0rhehSuR9E/Pt9PjZdu0j8y3SQGgZXTPybb+X5qvNQ/GtnO91Pj1T8O16NwPQrXPwLVeOkmMdg/9tJNYhBY2T/m0CLb+X7aP9rO91Pjpds/zszMzMzM3D/CyqFFtvPdP7bIdr6fGt8/VeOlm8Qg4D9PYhBYObTgP0nhehSuR+E/Q2Dl0CLb4T8930+Nl27iPzdeukkMAuM/Md0kBoGV4z8rXI/C9SjkPyXb+X5qvOQ/H1pkO99P5T8X2c73U+PlPxFYObTIduY/C9ejcD0K5z8FVg4tsp3nP//UeOkmMeg/+VPjpZvE6D/z0k1iEFjpP+1RuB6F6+k/59Ai2/l+6j/hT42XbhLrP9vO91Pjpes/1U1iEFg57D/NzMzMzMzsPw==",
        "encoding": "base64",
        "path": [
         "_data",
         0,
         "x",
         "value"
        ]
       },
       {
        "data": "2Mj2jvJoyT+I/EZE0bLMPziYajy0zM8/yL6AOUxe0T9gS/nzh8PSPyaASEfaF9Q/wCGRobdc1T+iVGj/UpPWPzYsVJ2tvNc/smsmAaLZ2D+OHxv36+rZP8atxn4u8do/LFgJSPjs2z+W/Dopx97cP9KXmdUKx90/I3YkBSem3j9XBqgwdXzfP1q7hP0iJeA/qgMZLfGH4D+OXaRGxubgP0GQR3XAQeE/HMRjRvuY4T/HgiDzj+zhP3IUKJ+VPOI/OOh8jiGJ4j87d+hTR9LiP+BcOPkYGOM/KnhDIqda4z9/sIIrAZrjP+li5EQ11uM/iFBkiVAP5D8cd9oTX0XkP35HYBFseOQ/Zz6c0YGo5D+ePjfVqdXkP/OetNrs/+Q/dTrd6VIn5T9dnOZd40vlP7ZWee6kbeU/Tnq0t52M5T+X1EdB06jlP2/ouoRKwuU/zmzz8gfZ5T+lYAt5D+3lPw5ihIRk/uU/4ODjBgoN5j8c7MF4AhnmP0ezUtxPIuY/cldxv/Mo5j/CSjE97yzmP+85+v5CLuY/wkoxPe8s5j9yV3G/8yjmP0ezUtxPIuY/HOzBeAIZ5j/g4OMGCg3mPw5ihIRk/uU/pWALeQ/t5T/NbPPyB9nlP27ouoRKwuU/l9RHQdOo5T9NerS3nYzlP7ZWee6kbeU/XZzmXeNL5T90Ot3pUiflP/OetNrs/+Q/nj431anV5D9nPpzRgajkP3xHYBFseOQ/HHfaE19F5D+HUGSJUA/kP+li5EQ11uM/frCCKwGa4z8peEMip1rjP+BcOPkYGOM/O3foU0fS4j846HyOIYniP3IUKJ+VPOI/x4Ig84/s4T8cxGNG+5jhP0CQR3XAQeE/jl2kRsbm4D+oAxkt8YfgP1i7hP0iJeA/VQaoMHV83z8fdiQFJ6beP86XmdUKx90/kvw6Kcfe3D8mWAlI+OzbP8Ktxn4u8do/ih8b9+vq2T+sayYBotnYPzQsVJ2tvNc/olRo/1KT1j+8IZGht1zVPySASEfaF9Q/Wkv584fD0j/EvoA5TF7RPzCYajy0zM8/gPxGRNGyzD/YyPaO8mjJPw==",
        "encoding": "base64",
        "path": [
         "_data",
         0,
         "y",
         "value"
        ]
       }
      ],
      "model_module": "plotlywidget",
      "model_module_version": "^0.7.1",
      "model_name": "FigureModel",
      "state": {
       "_config": {
        "plotlyServerURL": "https://plot.ly"
       },
       "_data": [
        {
         "name": "H[x]",
         "type": "scatter",
         "uid": "50137166-0090-46b3-9f23-5e86084c4fbe",
         "x": {
          "dtype": "float64",
          "shape": [
           101
          ]
         },
         "y": {
          "dtype": "float64",
          "shape": [
           101
          ]
         }
        }
       ],
       "_js2py_layoutDelta": {
        "layout_delta": {
         "annotations": [],
         "autosize": true,
         "calendar": "gregorian",
         "clickmode": "event",
         "colorscale": {
          "diverging": [
           [
            0,
            "rgb(5,10,172)"
           ],
           [
            0.35,
            "rgb(106,137,247)"
           ],
           [
            0.5,
            "rgb(190,190,190)"
           ],
           [
            0.6,
            "rgb(220,170,132)"
           ],
           [
            0.7,
            "rgb(230,145,90)"
           ],
           [
            1,
            "rgb(178,10,28)"
           ]
          ],
          "sequential": [
           [
            0,
            "rgb(220,220,220)"
           ],
           [
            0.2,
            "rgb(245,195,157)"
           ],
           [
            0.4,
            "rgb(245,160,105)"
           ],
           [
            1,
            "rgb(178,10,28)"
           ]
          ],
          "sequentialminus": [
           [
            0,
            "rgb(5,10,172)"
           ],
           [
            0.35,
            "rgb(40,60,190)"
           ],
           [
            0.5,
            "rgb(70,100,245)"
           ],
           [
            0.6,
            "rgb(90,120,245)"
           ],
           [
            0.7,
            "rgb(106,137,247)"
           ],
           [
            1,
            "rgb(220,220,220)"
           ]
          ]
         },
         "colorway": [
          "#1f77b4",
          "#ff7f0e",
          "#2ca02c",
          "#d62728",
          "#9467bd",
          "#8c564b",
          "#e377c2",
          "#7f7f7f",
          "#bcbd22",
          "#17becf"
         ],
         "dragmode": "zoom",
         "font": {
          "color": "#444",
          "family": "\"Open Sans\", verdana, arial, sans-serif",
          "size": 12
         },
         "height": 470,
         "hidesources": false,
         "hoverdistance": 20,
         "hoverlabel": {
          "font": {
           "family": "Arial, sans-serif",
           "size": 13
          },
          "namelength": 15
         },
         "hovermode": "x",
         "images": [],
         "margin": {
          "autoexpand": true,
          "b": 80,
          "l": 80,
          "pad": 0,
          "r": 80,
          "t": 100
         },
         "modebar": {
          "activecolor": "rgba(68, 68, 68, 0.7)",
          "bgcolor": "rgba(255, 255, 255, 0.5)",
          "color": "rgba(68, 68, 68, 0.3)",
          "orientation": "h"
         },
         "paper_bgcolor": "#fff",
         "plot_bgcolor": "#fff",
         "separators": ".,",
         "shapes": [],
         "showlegend": false,
         "sliders": [],
         "spikedistance": 20,
         "title": {
          "font": {
           "color": "#444",
           "family": "\"Open Sans\", verdana, arial, sans-serif",
           "size": 17
          },
          "pad": {
           "b": 0,
           "l": 0,
           "r": 0,
           "t": 0
          },
          "text": "Click to enter Plot title",
          "x": 0.5,
          "xanchor": "auto",
          "xref": "container",
          "y": "auto",
          "yanchor": "auto",
          "yref": "container"
         },
         "updatemenus": [],
         "width": 985.469,
         "xaxis": {
          "anchor": "y",
          "automargin": false,
          "autorange": true,
          "color": "#444",
          "constrain": "range",
          "constraintoward": "center",
          "domain": [
           0,
           1
          ],
          "dtick": 0.2,
          "exponentformat": "B",
          "fixedrange": false,
          "gridcolor": "rgb(238, 238, 238)",
          "gridwidth": 1,
          "hoverformat": "",
          "layer": "above traces",
          "nticks": 0,
          "range": [
           -0.9,
           0.9
          ],
          "rangemode": "normal",
          "separatethousands": false,
          "showexponent": "all",
          "showgrid": true,
          "showline": false,
          "showspikes": false,
          "showticklabels": true,
          "side": "bottom",
          "tick0": 0,
          "tickangle": "auto",
          "tickfont": {
           "color": "#444",
           "family": "\"Open Sans\", verdana, arial, sans-serif",
           "size": 12
          },
          "tickformat": "",
          "tickmode": "auto",
          "tickprefix": "",
          "ticks": "",
          "ticksuffix": "",
          "title": {
           "font": {
            "color": "#444",
            "family": "\"Open Sans\", verdana, arial, sans-serif",
            "size": 14
           },
           "text": "Click to enter X axis title"
          },
          "type": "linear",
          "visible": true,
          "zeroline": true,
          "zerolinecolor": "#444",
          "zerolinewidth": 1
         },
         "yaxis": {
          "anchor": "x",
          "automargin": false,
          "autorange": true,
          "color": "#444",
          "constrain": "range",
          "constraintoward": "middle",
          "domain": [
           0,
           1
          ],
          "dtick": 0.1,
          "exponentformat": "B",
          "fixedrange": false,
          "gridcolor": "rgb(238, 238, 238)",
          "gridwidth": 1,
          "hoverformat": "",
          "layer": "above traces",
          "nticks": 0,
          "range": [
           0.17103569127842408,
           0.7206267326273937
          ],
          "rangemode": "normal",
          "separatethousands": false,
          "showexponent": "all",
          "showgrid": true,
          "showline": false,
          "showspikes": false,
          "showticklabels": true,
          "side": "left",
          "tick0": 0,
          "tickangle": "auto",
          "tickfont": {
           "color": "#444",
           "family": "\"Open Sans\", verdana, arial, sans-serif",
           "size": 12
          },
          "tickformat": "",
          "tickmode": "auto",
          "tickprefix": "",
          "ticks": "",
          "ticksuffix": "",
          "title": {
           "font": {
            "color": "#444",
            "family": "\"Open Sans\", verdana, arial, sans-serif",
            "size": 14
           },
           "text": "Click to enter Y axis title"
          },
          "type": "linear",
          "visible": true,
          "zeroline": true,
          "zerolinecolor": "#444",
          "zerolinewidth": 1
         }
        },
        "layout_edit_id": 0
       },
       "_js2py_pointsCallback": {
        "device_state": {
         "alt": false,
         "button": 0,
         "buttons": 0,
         "ctrl": false,
         "meta": false,
         "shift": false
        },
        "event_type": "plotly_unhover",
        "points": {
         "point_indexes": [
          38
         ],
         "trace_indexes": [
          0
         ],
         "xs": [
          -0.21599999999999997
         ],
         "ys": [
          0.6696343095488462
         ]
        },
        "selector": null
       },
       "_js2py_relayout": {},
       "_js2py_restyle": {},
       "_js2py_traceDeltas": {
        "trace_deltas": [
         {
          "connectgaps": false,
          "error_x": {
           "visible": false
          },
          "error_y": {
           "visible": false
          },
          "fill": "none",
          "hoverinfo": "x+y+z+text",
          "hoverlabel": {
           "font": {
            "family": "Arial, sans-serif",
            "size": 13
           },
           "namelength": 15
          },
          "hoveron": "points",
          "hovertemplate": "",
          "hovertext": "",
          "index": 0,
          "legendgroup": "",
          "line": {
           "color": "#1f77b4",
           "dash": "solid",
           "shape": "linear",
           "simplify": true,
           "width": 2
          },
          "mode": "lines",
          "opacity": 1,
          "showlegend": true,
          "stackgroup": "",
          "text": "",
          "uid": "50137166-0090-46b3-9f23-5e86084c4fbe",
          "visible": true,
          "xaxis": "x",
          "xcalendar": "gregorian",
          "yaxis": "y",
          "ycalendar": "gregorian"
         }
        ],
        "trace_edit_id": 0
       },
       "_js2py_update": {},
       "_layout": {
        "template": {}
       },
       "_py2js_addTraces": {},
       "_py2js_animate": {},
       "_py2js_deleteTraces": {},
       "_py2js_moveTraces": {},
       "_py2js_removeLayoutProps": {},
       "_py2js_removeTraceProps": {},
       "_py2js_restyle": {},
       "_py2js_update": {},
       "_view_count": 2
      }
     }
    },
    "version_major": 2,
    "version_minor": 0
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
